// This file is a part of Funky C++.
// Copyright (C) 2011  Valentin David
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#ifndef MIDI_EVENT_HH
# define MIDI_EVENT_HH

# include <jack/midiport.h>

namespace jack {

  struct midi_event {
  public:
    jack_midi_data_t data[4];

    midi_event() {
      data[0] = 0;
    }

    midi_event(const ::jack_midi_event_t* event) {
      size_t s = event->time;
      if (s > 4)
	s = 4;
      const jack_midi_data_t* buffer = event->buffer;
      for (size_t n = 0; (n < s); ++n)
	data[n] = buffer[n];
    }

    midi_event(midi_event&& other) {
      for (size_t n = 0; (n < 4); ++n)
	data[n] = std::move(other.data[n]);
    }

    midi_event(const midi_event& other) {
      for (size_t n = 0; (n < 4); ++n)
	data[n] = other.data[n];
    }

    midi_event& operator=(const midi_event& other) {
      for (size_t n = 0; (n < 4); ++n)
	data[n] = other.data[n];
      return *this;
    }
  };

}

#endif
